#define DEBUG
#include <cstdio>
#include <cstring>

using namespace std;

const int maxn=400, maxm=15000, inf=0x7fffffff;

int min(int a, int b) {
  return a<b ? a : b;
}

class Network {
public:
  int n, m=1, ind[maxn+1], to[2*maxm+1], val[2*maxm+1], cost[2*maxm+1], link[2*maxm+1], dis[maxn+1], cur[maxn+1];
  bool vis[maxn+1];

  void addSide(int u, int v, int a, int b) {
    m++;
    to[m] = v;
    val[m] = a;
    cost[m] = b;
    link[m] = ind[u];
    ind[u] = m;
  }

  void calcDis(int s) {
    memset(dis, 127, sizeof dis);
    static bool book[maxn+1];
    static int que[maxn+1];

    que[1] = s;
    book[s] = true;
    dis[s] = 0;
    for (int h=0, t=1; h!=t; ) {
      h = h%n+1;
      book[que[h]] = false;
      for (int i=ind[que[h]]; i; i=link[i]) {
	if (val[i] && dis[to[i]]>dis[que[h]]+cost[i]) {
	  dis[to[i]] = dis[que[h]]+cost[i];
	  if (!book[to[i]]) {
	    book[to[i]] = true;
	    t = t%n+1;
	    que[t] = to[i];
	  }
	}
      }
    }
  }

  int runFlow(int o, int t, int flow, int &money) {
    if (o==t) {
      return flow;
    }
    vis[o] = true;
    int have=0, run=0;
    for (int i=cur[o]; i && have<flow; i=link[i]) {
      if (!vis[to[i]] && val[i] && dis[to[i]] == dis[o]+cost[i]) {
	run = runFlow(to[i], t, min(flow-have, val[i]), money);
	have += run, val[i] -= run, val[i^1] += run, money += run*cost[i];
      }
      cur[o] = i;
    }
    vis[o] = false;
    return have;
  }

  int solve(int s, int t, int &flow) {
    int ret=0;
    flow = 0;
    for (calcDis(s); dis[t]<=50000000; calcDis(s)) {
      for (int i=1; i<=n; i++) {
	cur[i] = ind[i];
	vis[i] = false;
      }
      flow += runFlow(s, t, inf, ret);
    }
    return ret;
  }
};

int main() {
#ifdef DEBUG
  freopen("src.in", "r", stdin);
  freopen("src.out", "w", stdout);
#endif

  static Network net;
  int n, m;
  scanf("%d %d", &n, &m);
  net.n = n;
  for (int i=1; i<=m; i++) {
    int u, v, a, b;
    scanf("%d %d %d %d", &u, &v, &a, &b);
    net.addSide(u, v, a, b);
    net.addSide(v, u, 0, -b);
  }

  int a, b;
  a=net.solve(1, n, b);
  printf("%d %d", b, a);

  fclose(stdin);
  fclose(stdout);
  return 0;
}
